package com.example.saiweisi.service.impl.sysTemAdminService;

import com.example.saiweisi.controller.request.ClothesMaterialRequest;
import com.example.saiweisi.mapper.systemAdminMapper.ClothesMaterialMapper;
import com.example.saiweisi.model.ClothesMaterial;
import com.example.saiweisi.model.ClothesMaterialWashKind;
import com.example.saiweisi.service.interf.IClothesMaterialService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ClothesMaterialService implements IClothesMaterialService {
    @Resource
    ClothesMaterialMapper clothesMaterialMapper;
    @Override
    public PageInfo<ClothesMaterialWashKind> page(ClothesMaterialRequest clothesMaterialRequest) {
        PageHelper.startPage(clothesMaterialRequest.getPageNum(), clothesMaterialRequest.getPageSize());
        List<ClothesMaterialWashKind> clothesMaterialList = clothesMaterialMapper.clothesMateriallistByCondition(clothesMaterialRequest);
        return new PageInfo<>(clothesMaterialList);

    }

    @Override
    public void addclothesMaterial(ClothesMaterial clothesMaterial) {
        clothesMaterialMapper.addclothesMaterial(clothesMaterial);
    }

    @Override
    public void deleteclothesMaterial(Integer clothesMaterialId) {
        clothesMaterialMapper.deleteclothesMaterial(clothesMaterialId);
    }

    @Override
    public void deletesclothesMaterial(List<Integer> clothesMaterialIds) {
        for (Integer a:clothesMaterialIds
        ) {
            clothesMaterialMapper.deleteclothesMaterial(a);
        }
    }

    @Override
    public void saveclothesMaterial(List<ClothesMaterialRequest> clothesMaterialRequestList) {
        for (ClothesMaterialRequest clothesMaterial:clothesMaterialRequestList
             ) {
            clothesMaterialMapper.updateclothesMaterial(clothesMaterial);
        }
    }

    @Override
    public List<ClothesMaterialWashKind> getall() {

        return clothesMaterialMapper.getall();
    }
}
